package cn.edu.zzuli.jucUtils;

import java.util.concurrent.CountDownLatch;

/**
 * @Date: 2021/3/8 19:24
 * @Author: 绯色下午茶
 * @Description:
 */

public class CountDownLatchDemo {
    public static void main(String []args) throws InterruptedException {
        CountDownLatch countDownLatch = new CountDownLatch(6);
        for (int i = 1; i <=  6; i++) {
            new Thread(()->{
                countDownLatch.countDown();
                System.out.println("第"+Thread.currentThread().getName()+"个同学离开了教室");
            },""+i).start();

        }
        countDownLatch.await();
        System.out.println("关门");
    }
    public  void closeDoor(String []args){
        for (int i = 0; i < 5; i++) {
            new Thread(()->{
                System.out.println("第"+Thread.currentThread().getName()+"个同学离开了教室");
            },""+i).start();

        }
        System.out.println("关门");
    }
}
